Core.Storage.Dao = function() {};

Core.Storage.Dao.prototype = {
	
	__clear: function() {},
	
	/**
	 * Creates dao expression.
	 * Return value will enable to get & set the given path from the specified storage.
	 */
	create: function(storage, path, instant) {
		return {
			__type: (instant ? "instant" : "deffered"),
			get: function(sub) {
				return storage.get(path + (sub || ""), (instant ? null : this.trace));
			},
			set: function(value, sub) {
				storage.set(path + (sub || ""), value);
			}
		}
	},
	
	/**
	 * Returns true if the given expression is an instant dao expression.
	 * @param Any e
	 */
	isInstant: function(e) {
		return e && e.__type == "instant" && e.get && e.set;
	},
	
	/**
	 * Returns true if the given expression is a deffered dao expression.
	 * @param Any e
	 */
	isDeffered: function(e) {
		return e && e.__type == "deffered" && e.get && e.set;		
	}
};

Core.Storage.Dao = Singleton.register("core.storage.dao", Core.Storage.Dao);

/**
 * Returns true if the given object is a dao expression.
 * @param Any o
 */
Lang.isDao = function(o) {
	return Core.Storage.Dao.isDeffered(o) ||  Core.Storage.Dao.isInstant(o);
};